package com.shan.thread;

/**
 * description
 * 测试睡眠
 *
 * @author shanzheng <br/>
 * @date 18:30 2019/1/11.<br/>
 * Modified By <br/>
 */
public class SleepThreadDemo {
    public static void main(String[] args) {
        SleepThread sleepThread = new SleepThread();
        Thread thread = new Thread(sleepThread, "睡眠线程");
        thread.start();
    }
}

class SleepThread implements Runnable {

    @Override
    public void run() {
        for (int i = 0; i < 50; i++) {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {

            }
            // 获取当前线程的名字
            System.out.println(i + "===>" + Thread.currentThread().getName());
        }
    }
}